<?php

// phpMyRealty 3
//
// File Name: index.php
// File Location : ./admin/
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

// Include configuration file and general functions
define('PMR', 'true');
define('PMRADMIN', 'true');

include ( '.././config.php' );
include ( PATH . '/defaults.php' );

// ----------------------------------------------------------------------
// ADMINISTRATOR PANEL

// Title tag 
$title = $lang['Module_Admin'];

// Template header
include ( PATH . '/admin/template/header.php' );

if (!isset($_SESSION['adminlogin']) && isset($_POST['login']))
 {
  $session->set('adminlogin', safehtml(strtolower($_POST['login'])));
  $session->set('adminpassword', md5($_POST['password']));
  $userlogin = FALSE;
 }

// If logged we can start the page output
if (adminAuth($session->fetch('adminlogin'), $session->fetch('adminpassword')))
 {

  $session->varunset('navigation');
  include ( PATH . '/admin/navigation.php' );

  echo table_header('Statistics');
  include ( PATH . '/admin/stats.php');
  echo table_footer();

 }

else

 {

  // IF NOT LOGGED

  // If this form was already submitted and 
  // login / password are not correct
  // we destroy the session

  if (isset($_SESSION['adminlogin'])
  && !adminAuth($session->fetch('adminlogin'), $session->fetch('adminpassword')) 
  && isset($_POST['login'])) 

   $session->destroy();

  echo table_header ( $lang['Module_Admin'] );

  // Output the form
  echo '
   <form action="' . URL . '/admin/index.php" method="POST">
    <table width="100%" cellpadding="5" cellspacing="0" border="0">
       ';

  echo userform ($lang['Admin_Login'], '<input type="text" size="45" name="login" maxlength="50">');
  echo userform ($lang['Admin_Password'], '<input type="password" size="45" name="password" maxlength="50">');
  echo userform ('', '<input type="submit" value="' . $lang['Admin_Login_Submit'] . '">');
 
  echo '
    </table>
   </form>
       ';

  echo table_footer ();

  if (isset($userlogin) && !$userlogin = FALSE) 
   echo '<span class="warning">' . $lang['Auth_Error'] . '</span><br /><br />';

 }

$version_check = TRUE;
$announcement_check = TRUE;

// Template footer
include ( PATH . '/admin/template/footer.php' );

?>